package com.qidian.mes.pro.controller;

import com.qidian.mes.pojo.Compose;
import com.qidian.mes.pro.service.ComposeService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author dqy
 * @Description
 * @Time 2024/4/13 9:27
 */
@RestController
@RequestMapping("/compose")
@CrossOrigin(allowedHeaders = "*")
public class ComposeController {
    @Autowired
    private ComposeService composeService;

    /**
     * @Description: 保存工艺
     * @Param: [compose]
     * @return: com.qidian.mes.util.pojo.QdResult
     */
    @PostMapping("/saveCompose")
    public QdResult saveCompose(@RequestBody Compose compose){
        return composeService.saveCompose(compose);
    }
    /*
     * @Description: 根据工艺id查询工序
     * @Param: [processId]
     */
    @GetMapping("/queryById")
    public QdResult<Compose> queryById(Long composeId){
        return composeService.queryById(composeId);
    }
    /**
     * @Description: 根据工艺id删除工艺
     * @Param: [techniqueId]
     * @return: com.qidian.mes.util.pojo.QdResult
     */
    @GetMapping("/delete")
    public QdResult deleteById(Long composeId){
        return composeService.deleteById(composeId);
    }
    /** 批量删除工艺 */
    @GetMapping("/deletes")
    public QdResult deletes(Long [] composeIds){
        return composeService.deletes(composeIds);
    }
    /**
     * @Description: 更新工艺
     * @Param: [compose]
     * @return: com.qidian.mes.util.pojo.QdResult
     */
    @PostMapping("/update")
    public QdResult updateCompose(@RequestBody Compose compose){
        System.out.println("更新工艺调用"+compose);
        return composeService.updateCompose(compose);
    }
    /**
     * @Description: 分页查询工艺组成
     * @Param: [compose, page, limit]
     * @return: com.qidian.mes.util.pojo.QdResult
     */
    @GetMapping("/queryByPage")
    public QdResult<PagerDTO<Compose>> queryByPage(Compose compose, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit){
        System.out.println("分页查询工艺组成调用"+compose);
        return composeService.queryByPage(compose,page,limit);
    }



}
